<script src="<?php print base_url(); ?>public/jquery/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="<?php print base_url(); ?>public/ajax/ajaxFileUpload/ajaxfileupload.js" rel="forceLoad"></script>

<script>
    $(document).ready(function(){
        $("#update_paper").submit(function(e){
            e.preventDefault();
            var url = baseurl + "admin/updatePaper";
            var id = <?php echo $data['id']?>;
            var description = document.getElementById("update_description").value;
            var date = document.getElementById("update_date").value;
            var name = document.getElementById("update_name").value;
            var update_file = document.getElementById("update_file").value;
//            alert(id)
//            alert(description)
//            alert(date)
//            alert(name)
//            alert(file)
            $.ajaxFileUpload({
                url: url,
                secureuri:false,
                fileElementId: 'update_file',
                dataType: 'json',
                data: {
                    'id': id,
                    'date': date,
                    'name': name,
                    'description': description,
                    'file': update_file
                },
                success: function(data, status){
                    alert(data.msg);
                    var page = baseurl + 'admin/showPaper';
                    $.get(page)
                    .success(function(data) {
                        $('div#content').html(data);
                    });
                    $.nmTop().close();
                }
            
            
            })
        });
    })
</script>

<h4>Update Paper</h4>
<hr>
<div class="row">
    <form method='post' id="update_paper" action="?" style="width: 600px">
        <fieldset style="width: 570px">
            <legend>Edit Paper</legend>
            <ul class="inline">
                <li class="field">
                    <label class="inline" style="width: 30%">Publication Date&nbsp;</label>
                    <input class="wide text input" type="date" placeholder="Text input" name="update_date" id="update_date" value="<?php echo $data['date']; ?>"/>
                </li>
                <li class="field">
                    <label class="inline" style="width: 30%">Name</label>
                    <input class="wide input textarea" type="text" placeholder="Name" name="update_name" id="update_name" value="<?php echo $data['name']; ?>"/>
                </li>
                <li class="field">
                    <label class="inline" style="width: 30%; vertical-align: top">Description &nbsp;</label>
                    <textarea class="wide text input" type="textarea" style="width: 300px; height: 100px;" placeholder="Description" name="update_description" id="update_description"><?php echo $data['description']; ?></textarea>
                </li>
                <li class="field">
                    <label class="inline" style="width: 30%">File &nbsp;</label>
                    <input class="wide input" type="file" name="update_file" id="update_file"/>
                </li>
                <li>
                    <label class="inline" style="width: 30%">&nbsp;&nbsp;&nbsp;</label>
                    <div class="pretty medium default btn"><input type="submit" value="Save"></div>
                </li>
            </ul>
        </fieldset>
    </form>
</div>
